package com.djzh.insightconnector.mockproject.mock;

import com.djzh.insightconnector.mockproject.domain.CaStoreCertRequest;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/ca/app/v1")
public class CaMockApiController {

    /**
     * 生成CSR
     * @return CSR
     */
    @PostMapping("/genCsr")
    public Map<String, Object> genCsr() {
        Map<String, Object> result = new HashMap<>();
        result.put("code", "0");
        result.put("msg", "成功");
        result.put("data", "MIIBBjCBrQIBADBLMQkwBwYDVQQGEwAxCTAHBgNVBAoMADEzMDEGA1UEAwwq5Lit5Zu956e75Yqo6YCa5L+h6ZuG5Zui5aSp5rSl5pyJ6ZmQ5YWs5Y+4MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEz9Emrow4hKnh1sDRcaMN0HhpV8EjvRInH9d/xKJCXLgk9jism2eH+AMlp+E8okSi+fn+hi5lW2P14fFpWxMHHaAAMAoGCCqBHM9VAYN1A0gAMEUCIQC4hJsk7XA12mXkExZ7DECFRlUVE8I8mhYsYvyR22QnNwIgLIgz0UQrJ7klbRh2b80057zoFyhfWBm6I6dupFJdgdQ=");
        return result;
    }


    /**
     * 安全存储证书
     * @return 存储结果
     */
    @PostMapping("/storeCert")
    public Map<String, Object> storeCert(@RequestBody CaStoreCertRequest request) {
        Map<String, Object> data = new HashMap<>();
        data.put("stored", true);
        data.put("certId", "certId");

        Map<String, Object> result = new HashMap<>();
        result.put("code", "0");
        result.put("msg", "success");
        result.put("data", data);

        return result;
    }
}
